<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-transform" />
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="format-detection" content="telephone=no,email=no,adress=no">
  <!-- Color theme for statusbar -->
  <meta name="theme-color" content="#000000" />
  <!-- 强制页面在当前窗口以独立页面显示,防止别人在框架里调用页面 -->
  <meta http-equiv="window-target" content="_top" />
  
  
  <title>JavaSE_02 | 金旭的个人博客</title>
  <meta name="description" content="一维数组和二维数组的初始化方式12345678&#x2F;&#x2F; 一维数组的动态初始化int[] array &#x3D; new int[3];&#x2F;&#x2F; 一维数组的静态初始化int[] array &#x3D; new int[]&amp;#123;1,2,3&amp;#125;;&#x2F;&#x2F; 二维数组的动态初始化int[][] array &#x3D; new int[3][3];&#x2F;&#x2F; 二维数组的静态初始化int[][] array &#x3D; new int[][]&amp;#">
<meta property="og:type" content="article">
<meta property="og:title" content="JavaSE_02">
<meta property="og:url" content="http://sunjinxu99.gitee.io/blog/2020/04/12/javaSE_02/index.html">
<meta property="og:site_name" content="金旭的个人博客">
<meta property="og:description" content="一维数组和二维数组的初始化方式12345678&#x2F;&#x2F; 一维数组的动态初始化int[] array &#x3D; new int[3];&#x2F;&#x2F; 一维数组的静态初始化int[] array &#x3D; new int[]&amp;#123;1,2,3&amp;#125;;&#x2F;&#x2F; 二维数组的动态初始化int[][] array &#x3D; new int[3][3];&#x2F;&#x2F; 二维数组的静态初始化int[][] array &#x3D; new int[][]&amp;#">
<meta property="og:image" content="https://gitee.com/sunjinxu99/image/raw/master/img/20200408091048.png">
<meta property="og:image" content="https://gitee.com/sunjinxu99/image/raw/master/img/20200413080958.png">
<meta property="og:image" content="https://gitee.com/sunjinxu99/image/raw/master/img/20200413081553.png">
<meta property="article:published_time" content="2020-04-12T03:21:54.437Z">
<meta property="article:modified_time" content="2020-04-13T03:19:47.115Z">
<meta property="article:author" content="金旭">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/sunjinxu99/image/raw/master/img/20200408091048.png">
  <!-- Canonical links -->
  <link rel="canonical" href="http://sunjinxu99.gitee.io/blog/2020/04/12/javaSE_02/index.html">
  
    <link rel="alternate" href="/atom.xml" title="金旭的个人博客" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png" type="image/x-icon">
  
  
<link rel="stylesheet" href="/blog/css/style.css">

  
  
  
  
<meta name="generator" content="Hexo 4.2.0"></head>


<body class="main-center theme-blue# 主题颜色 theme-black theme-blue theme-green theme-purple" itemscope itemtype="http://schema.org/WebPage">
  <header class="header" itemscope itemtype="http://schema.org/WPHeader">
  <div class="slimContent">
    <div class="navbar-header">
      
      
      <div class="profile-block text-center">
        <a id="avatar" href="" target="_blank">
          <img class="img-circle img-rotate" src="/blog/images/avatar.png" width="200" height="200">
        </a>
        <h2 id="name" class="hidden-xs hidden-sm">小马</h2>
        <h3 id="title" class="hidden-xs hidden-sm hidden-md"></h3>
        <small id="location" class="text-muted hidden-xs hidden-sm"><i class="icon icon-map-marker"></i> </small>
      </div>
      
      <div class="search" id="search-form-wrap">

    <form class="search-form sidebar-form">
        <div class="input-group">
            <input type="text" class="search-form-input form-control" placeholder="Search" />
            <span class="input-group-btn">
                <button type="submit" class="search-form-submit btn btn-flat" onclick="return false;"><i class="icon icon-search"></i></button>
            </span>
        </div>
    </form>
    <div class="ins-search">
  <div class="ins-search-mask"></div>
  <div class="ins-search-container">
    <div class="ins-input-wrapper">
      <input type="text" class="ins-search-input" placeholder="Type something..." x-webkit-speech />
      <button type="button" class="close ins-close ins-selectable" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
    </div>
    <div class="ins-section-wrapper">
      <div class="ins-section-container"></div>
    </div>
  </div>
</div>


</div>
      <button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target="#main-navbar" aria-controls="main-navbar" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
    </div>
    <nav id="main-navbar" class="collapse navbar-collapse" itemscope itemtype="http://schema.org/SiteNavigationElement" role="navigation">
      <ul class="nav navbar-nav main-nav ">
        
        
        <li class="menu-item menu-item-home">
          <a href="/blog/.">
            
            <i class="icon icon-home-fill"></i>
            
            <span class="menu-title">Home</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives">
            
            <i class="icon icon-archives-fill"></i>
            
            <span class="menu-title">Archives</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-categories">
          <a href="/blog/categories">
            
            <i class="icon icon-folder"></i>
            
            <span class="menu-title">Categories</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-tags">
          <a href="/blog/tags">
            
            <i class="icon icon-tags"></i>
            
            <span class="menu-title">Tags</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-about">
          <a href="/blog/about">
            
            <i class="icon icon-cup-fill"></i>
            
            <span class="menu-title">About</span>
          </a>
        </li>
        
      </ul>
      
    </nav>
  </div>
</header>

  
    <aside class="sidebar" itemscope itemtype="http://schema.org/WPSideBar">
  <div class="slimContent">
    
      <div class="widget">
    <h3 class="widget-title">Board</h3>
    <div class="widget-body">
        <div id="board">
            <div class="content">
                <p>朝闻道夕死可矣</p>
            </div>
        </div>
    </div>
</div>

    
      
  <div class="widget">
    <h3 class="widget-title">Categories</h3>
    <div class="widget-body">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/blog/categories/JavaSE/">JavaSE</a><span class="category-list-count">7</span></li><li class="category-list-item"><a class="category-list-link" href="/blog/categories/LeetCode/">LeetCode</a><span class="category-list-count">3</span><ul class="category-list-child"><li class="category-list-item"><a class="category-list-link" href="/blog/categories/LeetCode/%E7%AE%97%E6%B3%95/">算法</a><span class="category-list-count">3</span></li></ul></li><li class="category-list-item"><a class="category-list-link" href="/blog/categories/%E6%9D%82%E8%AE%B0/">杂记</a><span class="category-list-count">1</span></li></ul>
    </div>
  </div>


    
      
  <div class="widget">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget-body tagcloud">
      <a href="/blog/tags/IO%E6%B5%81/" style="font-size: 13px;">IO流</a> <a href="/blog/tags/OSI%E5%8F%82%E8%80%83%E6%A8%A1%E5%9E%8B/" style="font-size: 13px;">OSI参考模型</a> <a href="/blog/tags/TCP-IP%E5%8F%82%E8%80%83%E6%A8%A1%E5%9E%8B/" style="font-size: 13px;">TCP/IP参考模型</a> <a href="/blog/tags/ftp%E5%8D%8F%E8%AE%AE/" style="font-size: 13px;">ftp协议</a> <a href="/blog/tags/http/" style="font-size: 13px;">http</a> <a href="/blog/tags/leetcode/" style="font-size: 13px;">leetcode</a> <a href="/blog/tags/%E4%BA%8C%E5%88%86%E6%95%B0%E7%BB%84/" style="font-size: 13px;">二分数组</a> <a href="/blog/tags/%E4%BA%8C%E5%8F%89%E6%A0%91/" style="font-size: 13px;">二叉树</a> <a href="/blog/tags/%E5%85%A8%E6%8E%92%E5%88%97/" style="font-size: 13px;">全排列</a> <a href="/blog/tags/%E5%8F%8C%E6%8C%87%E9%92%88/" style="font-size: 13.33px;">双指针</a> <a href="/blog/tags/%E5%8F%8D%E5%B0%84/" style="font-size: 13px;">反射</a> <a href="/blog/tags/%E5%93%88%E5%B8%8C%E8%A1%A8/" style="font-size: 13.67px;">哈希表</a> <a href="/blog/tags/%E5%9B%9E%E6%BA%AF%E6%B3%95/" style="font-size: 13px;">回溯法</a> <a href="/blog/tags/%E5%A4%9A%E7%BA%BF%E7%A8%8B/" style="font-size: 13px;">多线程</a> <a href="/blog/tags/%E5%AD%97%E7%AC%A6%E4%B8%B2/" style="font-size: 13px;">字符串</a> <a href="/blog/tags/%E6%8E%92%E5%BA%8F/" style="font-size: 13.33px;">排序</a> <a href="/blog/tags/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/" style="font-size: 14px;">数据结构</a> <a href="/blog/tags/%E6%9D%82%E8%AE%B0/" style="font-size: 13px;">杂记</a> <a href="/blog/tags/%E6%A0%88/" style="font-size: 13px;">栈</a> <a href="/blog/tags/%E6%B3%9B%E5%9E%8B/" style="font-size: 13px;">泛型</a> <a href="/blog/tags/%E7%AE%97%E6%B3%95/" style="font-size: 13.33px;">算法</a> <a href="/blog/tags/%E8%8F%B2%E6%B3%A2%E9%82%A3%E5%88%87%E6%95%B0%E5%88%97/" style="font-size: 13.33px;">菲波那切数列</a> <a href="/blog/tags/%E9%80%92%E5%BD%92/" style="font-size: 13px;">递归</a> <a href="/blog/tags/%E9%93%BE%E8%A1%A8/" style="font-size: 13.33px;">链表</a> <a href="/blog/tags/%E9%98%9F%E5%88%97/" style="font-size: 13px;">队列</a> <a href="/blog/tags/%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1/" style="font-size: 13px;">面向对象</a>
    </div>
  </div>

    
      
  <div class="widget">
    <h3 class="widget-title">Archive</h3>
    <div class="widget-body">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2021/07/">July 2021</a><span class="archive-list-count">9</span></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2020/07/">July 2020</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2020/05/">May 2020</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2020/04/">April 2020</a><span class="archive-list-count">8</span></li><li class="archive-list-item"><a class="archive-list-link" href="/blog/archives/2020/03/">March 2020</a><span class="archive-list-count">10</span></li></ul>
    </div>
  </div>


    
      
  <div class="widget">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget-body">
      <ul class="recent-post-list list-unstyled no-thumbnail">
        
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                
              </p>
              <p class="item-title">
                <a href="/blog/2021/07/14/%E4%BA%8C%E5%8F%89%E6%A0%91%E7%9A%84%E9%95%9C%E5%83%8F/" class="title">二叉树的镜像</a>
              </p>
              <p class="item-date">
                <time datetime="2021-07-14T12:34:40.165Z" itemprop="datePublished">2021-07-14</time>
              </p>
            </div>
          </li>
          
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                
              </p>
              <p class="item-title">
                <a href="/blog/2021/07/14/%E5%90%88%E5%B9%B6%E4%B8%A4%E4%B8%AA%E6%8E%92%E5%BA%8F%E7%9A%84%E9%93%BE%E8%A1%A8/" class="title">合并两个排序的链表</a>
              </p>
              <p class="item-date">
                <time datetime="2021-07-14T09:26:07.612Z" itemprop="datePublished">2021-07-14</time>
              </p>
            </div>
          </li>
          
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                
              </p>
              <p class="item-title">
                <a href="/blog/2021/07/14/%E4%BB%8E%E5%B0%BE%E5%88%B0%E5%A4%B4%E6%89%93%E5%8D%B0%E9%93%BE%E8%A1%A8/" class="title">从尾到头打印链表</a>
              </p>
              <p class="item-date">
                <time datetime="2021-07-14T08:02:42.111Z" itemprop="datePublished">2021-07-14</time>
              </p>
            </div>
          </li>
          
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                
              </p>
              <p class="item-title">
                <a href="/blog/2021/07/14/%E6%9B%BF%E6%8D%A2%E7%A9%BA%E6%A0%BC/" class="title">替换空格</a>
              </p>
              <p class="item-date">
                <time datetime="2021-07-14T06:28:22.026Z" itemprop="datePublished">2021-07-14</time>
              </p>
            </div>
          </li>
          
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                
              </p>
              <p class="item-title">
                <a href="/blog/2021/07/14/%E6%97%8B%E8%BD%AC%E6%95%B0%E7%BB%84%E7%9A%84%E6%9C%80%E5%B0%8F%E6%95%B0%E5%AD%97/" class="title">旋转数组的最小数字</a>
              </p>
              <p class="item-date">
                <time datetime="2021-07-14T06:12:09.184Z" itemprop="datePublished">2021-07-14</time>
              </p>
            </div>
          </li>
          
      </ul>
    </div>
  </div>
  

    
  </div>
</aside>

  
  
<main class="main" role="main">
  <div class="content">
  <article id="post-javaSE_02" class="article article-type-post" itemscope itemtype="http://schema.org/BlogPosting">
    
    <div class="article-header">
      
        
  
    <h1 class="article-title" itemprop="name">
      JavaSE_02
    </h1>
  

      
      <div class="article-meta">
        <span class="article-date">
    <i class="icon icon-calendar-check"></i>
	<a href="/blog/2020/04/12/javaSE_02/" class="article-date">
	  <time datetime="2020-04-12T03:21:54.437Z" itemprop="datePublished">2020-04-12</time>
	</a>
</span>
        
  <span class="article-category">
    <i class="icon icon-folder"></i>
    <a class="article-category-link" href="/blog/categories/JavaSE/">JavaSE</a>
  </span>

        

        

        <span class="post-comment"><i class="icon icon-comment"></i> <a href="/blog/2020/04/12/javaSE_02/#comments" class="article-comment-link">Comments</a></span>
        
      </div>
    </div>
    <div class="article-entry marked-body" itemprop="articleBody">
      
        <h3 id="一维数组和二维数组的初始化方式"><a href="#一维数组和二维数组的初始化方式" class="headerlink" title="一维数组和二维数组的初始化方式"></a>一维数组和二维数组的初始化方式</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 一维数组的动态初始化</span></span><br><span class="line"><span class="keyword">int</span>[] array = <span class="keyword">new</span> <span class="keyword">int</span>[<span class="number">3</span>];</span><br><span class="line"><span class="comment">// 一维数组的静态初始化</span></span><br><span class="line"><span class="keyword">int</span>[] array = <span class="keyword">new</span> <span class="keyword">int</span>[]&#123;<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>&#125;;</span><br><span class="line"><span class="comment">// 二维数组的动态初始化</span></span><br><span class="line"><span class="keyword">int</span>[][] array = <span class="keyword">new</span> <span class="keyword">int</span>[<span class="number">3</span>][<span class="number">3</span>];</span><br><span class="line"><span class="comment">// 二维数组的静态初始化</span></span><br><span class="line"><span class="keyword">int</span>[][] array = <span class="keyword">new</span> <span class="keyword">int</span>[][]&#123;&#123;<span class="number">1</span>,<span class="number">2</span>&#125;,&#123;<span class="number">3</span>,<span class="number">4</span>&#125;,&#123;<span class="number">5</span>,<span class="number">6</span>&#125;&#125;;</span><br></pre></td></tr></table></figure>
<h3 id="遍历二维数组"><a href="#遍历二维数组" class="headerlink" title="遍历二维数组"></a>遍历二维数组</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">int</span>[][] arr = <span class="keyword">new</span> <span class="keyword">int</span>[][]&#123;&#123;<span class="number">1</span>,<span class="number">2</span>,<span class="number">3</span>&#125;,&#123;<span class="number">4</span>,<span class="number">5</span>&#125;,&#123;<span class="number">6</span>,<span class="number">7</span>,<span class="number">8</span>&#125;&#125;;</span><br><span class="line"><span class="keyword">for</span>(<span class="keyword">int</span> i,i&lt;arr.length,i++)&#123;</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> j,j&lt;arr[i].length,j++)&#123;</span><br><span class="line">        System.out.ptint(arr[i][j] + <span class="string">"\t"</span>);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="不同类型一维数组的初始化值"><a href="#不同类型一维数组的初始化值" class="headerlink" title="不同类型一维数组的初始化值"></a>不同类型一维数组的初始化值</h3><p>byte、long、int、short初始化值为0，float、double为0.0，bolean为false，char为’\u0000‘，引用类型为null</p>
<h3 id="一维数组的内存解析"><a href="#一维数组的内存解析" class="headerlink" title="一维数组的内存解析"></a>一维数组的内存解析</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">String[] str = <span class="keyword">new</span> String[<span class="number">5</span>];</span><br><span class="line">str[<span class="number">2</span>] = <span class="string">"Tom"</span>;</span><br><span class="line">str = <span class="keyword">new</span> String[<span class="number">3</span>]</span><br></pre></td></tr></table></figure>
<p>在堆中创建好对象String[5],并将地址值指向栈中的str，然后将索引为2的值改为”Tom”,新建一个长度为3的数组，并将新的地址指向str变量</p>
<h3 id="使用冒泡排序进行排序"><a href="#使用冒泡排序进行排序" class="headerlink" title="使用冒泡排序进行排序"></a>使用冒泡排序进行排序</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">int</span>[] arr = <span class="keyword">new</span> <span class="keyword">int</span>[]&#123;<span class="number">34</span>,<span class="number">5</span>,<span class="number">33</span>,-<span class="number">98</span>,<span class="number">6</span>,-<span class="number">76</span>,<span class="number">0</span>,-<span class="number">3</span>&#125;</span><br><span class="line"><span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">0</span>,i&lt;arr.lrngth,i++)&#123;</span><br><span class="line">    <span class="keyword">for</span>(<span class="keyword">int</span> j=<span class="number">0</span>,j&lt;arr.length-i,j++)&#123;</span><br><span class="line">        <span class="keyword">if</span>(arr[j]&gt;arr[j+<span class="number">1</span>])&#123;</span><br><span class="line">            <span class="keyword">int</span> tem = arr[j];</span><br><span class="line">            arr[j] = arr[j+<span class="number">1</span>];</span><br><span class="line">            arr[j+<span class="number">1</span>] = arr[j];</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="翻转上面的数组"><a href="#翻转上面的数组" class="headerlink" title="翻转上面的数组"></a>翻转上面的数组</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">0</span>,i&lt;arr.length/<span class="number">2</span>,i++)&#123;</span><br><span class="line">    <span class="keyword">int</span> temp = arr[i];</span><br><span class="line">    arr[i] = arr[arr.length-<span class="number">1</span>-i];</span><br><span class="line">    arr[arr.length-<span class="number">1</span>-i] = temp;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="数组中常见的异常"><a href="#数组中常见的异常" class="headerlink" title="数组中常见的异常"></a>数组中常见的异常</h3><p>数组下标越界，数组出现空指针</p>
<h3 id="面向对象中类和对象的解释"><a href="#面向对象中类和对象的解释" class="headerlink" title="面向对象中类和对象的解释"></a>面向对象中类和对象的解释</h3><p>类是将具有某种特征的一类对象，对象是类的实例化</p>
<h3 id="类和对象的创建和执行操作有哪三步"><a href="#类和对象的创建和执行操作有哪三步" class="headerlink" title="类和对象的创建和执行操作有哪三步"></a>类和对象的创建和执行操作有哪三步</h3><p>创建类，类的实例化，调用类的属性、方法</p>
<h3 id="什么是方法的重载"><a href="#什么是方法的重载" class="headerlink" title="什么是方法的重载"></a>什么是方法的重载</h3><p>同一个类，相同的方法；参数列表不同</p>
<h3 id="java方法中的参数传递机制"><a href="#java方法中的参数传递机制" class="headerlink" title="java方法中的参数传递机制"></a>java方法中的参数传递机制</h3><p>基本数据类型传递的是数据值，引用数据类型传递的是地址值。</p>
<h3 id="return关键字的作用"><a href="#return关键字的作用" class="headerlink" title="return关键字的作用"></a>return关键字的作用</h3><p>结束方法，返回要求类型的数值</p>
<h3 id="构造器的作用"><a href="#构造器的作用" class="headerlink" title="构造器的作用"></a>构造器的作用</h3><p>创建对象、初始化对象结构</p>
<h3 id="类的赋值的方式"><a href="#类的赋值的方式" class="headerlink" title="类的赋值的方式"></a>类的赋值的方式</h3><p>默认初始化-显示初始化-构造器中初始化-对象或方法赋值</p>
<h3 id="this关键字可以调用的结构"><a href="#this关键字可以调用的结构" class="headerlink" title="this关键字可以调用的结构"></a>this关键字可以调用的结构</h3><p>this为当前的对象，可以调用属性和方法</p>
<h3 id="四种权限修饰符"><a href="#四种权限修饰符" class="headerlink" title="四种权限修饰符"></a>四种权限修饰符</h3><p><img src="https://gitee.com/sunjinxu99/image/raw/master/img/20200408091048.png" alt=""></p>
<h3 id="如何实现向下转型"><a href="#如何实现向下转型" class="headerlink" title="如何实现向下转型"></a>如何实现向下转型</h3><p>使用强转符：（），Man m = (man)p，可以使用instanceof判断能否强转，可能出现的异常为ClassCastException</p>
<h3 id="和equals-的区别"><a href="#和equals-的区别" class="headerlink" title="==和equals()的区别"></a>==和equals()的区别</h3><p>比较引用数据类型，==和equals都是比较的地址，比较基础数据类型，==和equals都是作用于比较对象的内容，但equals有时会被重写</p>
<h3 id="写出8种基本数据类型及其对应的包装类"><a href="#写出8种基本数据类型及其对应的包装类" class="headerlink" title="写出8种基本数据类型及其对应的包装类"></a>写出8种基本数据类型及其对应的包装类</h3><p><img src="https://gitee.com/sunjinxu99/image/raw/master/img/20200413080958.png" alt=""></p>
<h3 id="基本数据类型、包装类和String三者之间如何转换"><a href="#基本数据类型、包装类和String三者之间如何转换" class="headerlink" title="基本数据类型、包装类和String三者之间如何转换"></a>基本数据类型、包装类和String三者之间如何转换</h3><p><img src="https://gitee.com/sunjinxu99/image/raw/master/img/20200413081553.png" alt=""></p>
<h3 id="重写equals"><a href="#重写equals" class="headerlink" title="重写equals"></a>重写equals</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">User</span></span>&#123;</span><br><span class="line">    String name;</span><br><span class="line">    <span class="keyword">int</span> age;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">boolean</span> <span class="title">equals</span><span class="params">(object obj)</span></span>&#123;</span><br><span class="line">        <span class="keyword">if</span>(obj == <span class="keyword">this</span>)&#123;</span><br><span class="line">            <span class="keyword">return</span> <span class="keyword">true</span>;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span>(obj <span class="keyword">instanceof</span> User)&#123;</span><br><span class="line">            <span class="keyword">return</span> <span class="keyword">this</span>.name==obj.name &amp;&amp; <span class="keyword">this</span>.age == obj.age;</span><br><span class="line"></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="static关键字"><a href="#static关键字" class="headerlink" title="static关键字"></a>static关键字</h3><p>随着类的加载而加载，早于对象的创建，可以通过对象.属性调用，存在于方法区的静态域中</p>
<h3 id="final可以修饰的结构"><a href="#final可以修饰的结构" class="headerlink" title="final可以修饰的结构"></a>final可以修饰的结构</h3><p>类、方法、成员变量用来表示不可被继承、修改</p>
<h3 id="单例模式中的饿汉式与懒汉式"><a href="#单例模式中的饿汉式与懒汉式" class="headerlink" title="单例模式中的饿汉式与懒汉式"></a>单例模式中的饿汉式与懒汉式</h3><p>单例模式是比较常见的一种设计模式，目的是保证一个类只能有一个实例，而且自行实例化并向整个系统提供这个实例，避免频繁创建对象，节约内存。首先构造器私有化、内部构建静态的对象、提供公共的静态的方法并返回类的对象</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//饿汉式</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Singleton</span></span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="title">Singleton</span><span class="params">()</span></span>&#123;</span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> Singleton instance = <span class="keyword">new</span> Singleton();</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> Singleton <span class="title">getinstance</span><span class="params">()</span></span>&#123;</span><br><span class="line">        <span class="keyword">return</span> instance;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">//懒汉式</span></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Singleton</span></span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="title">Singleton</span><span class="params">()</span></span>&#123;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">private</span> <span class="keyword">static</span> Singleton instance = <span class="keyword">null</span>;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> Singleton <span class="title">getinstance</span><span class="params">()</span></span>&#123;</span><br><span class="line">        <span class="keyword">if</span>(instance==<span class="keyword">null</span>)&#123;</span><br><span class="line">            instance =  <span class="keyword">new</span> Singletance();</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> instance;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="abstract修饰的结构"><a href="#abstract修饰的结构" class="headerlink" title="abstract修饰的结构"></a>abstract修饰的结构</h3><p>类、方法。类不能实例化。抽象方法只定义了一种功能的标准，如果需要执行，则要建立子类去实现。接口能继承接口、抽象类能实现接口、抽象类能继承非抽象的类</p>
<h3 id="抽象类和接口"><a href="#抽象类和接口" class="headerlink" title="抽象类和接口"></a>抽象类和接口</h3><p>相同点：不能实例化 都可以被继承 不同点：抽象类有构造器，接口不能声明构造器，接口可以被多继承</p>
<h3 id=""><a href="#" class="headerlink" title=""></a></h3>
      
    </div>
    <div class="article-footer">
      <blockquote class="mt-2x">
  <ul class="post-copyright list-unstyled">
    
    <li class="post-copyright-link hidden-xs">
      <strong>本文链接：</strong>
      <a href="http://sunjinxu99.gitee.io/blog/2020/04/12/javaSE_02/" title="JavaSE_02" target="_blank" rel="external">http://sunjinxu99.gitee.io/blog/2020/04/12/javaSE_02/</a>
    </li>
    
    <li class="post-copyright-license">
      <strong>版权声明： </strong> 本博客所有文章除特别声明外，均采用 <a href="http://creativecommons.org/licenses/by/4.0/deed.zh" target="_blank" rel="external">CC BY 4.0 CN协议</a> 许可协议。转载请注明出处！
    </li>
  </ul>
</blockquote>


<div class="panel panel-default panel-badger">
  <div class="panel-body">
    <figure class="media">
      <div class="media-left">
        <a href="" target="_blank" class="img-burn thumb-sm visible-lg">
          <img src="/blog/images/avatar.png" class="img-rounded w-full" alt="">
        </a>
      </div>
      <div class="media-body">
        <h3 class="media-heading"><a href="" target="_blank"><span class="text-dark">小马</span><small class="ml-1x"></small></a></h3>
        <div></div>
      </div>
    </figure>
  </div>
</div>


    </div>
  </article>
  
    
  <section id="comments">
  	
      <div id="vcomments"></div>
    
  </section>


  
</div>

  <nav class="bar bar-footer clearfix" data-stick-bottom>
  <div class="bar-inner">
  
  <ul class="pager pull-left">
    
    <li class="prev">
      <a href="/blog/2020/04/13/%E5%A4%9A%E7%BA%BF%E7%A8%8B/" title="多线程"><i class="icon icon-angle-left" aria-hidden="true"></i><span>&nbsp;&nbsp;Newer</span></a>
    </li>
    
    
    <li class="next">
      <a href="/blog/2020/04/12/IO%E6%B5%81/" title="IO流"><span>Older&nbsp;&nbsp;</span><i class="icon icon-angle-right" aria-hidden="true"></i></a>
    </li>
    
    
  </ul>
  
  
  
  <div class="bar-right">
    
  </div>
  </div>
</nav>
  


</main>

  <footer class="footer" itemscope itemtype="http://schema.org/WPFooter">
	
    <div class="copyright">
    	
        <div class="publishby">
        	Theme by <a href="https://github.com/cofess" target="_blank"> cofess </a>base on <a href="https://github.com/cofess/hexo-theme-pure" target="_blank">pure</a>.
        </div>
    </div>
</footer>
  <script src="//cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<script>
window.jQuery || document.write('<script src="js/jquery.min.js"><\/script>')
</script>

<script src="/blog/js/plugin.min.js"></script>


<script src="/blog/js/application.js"></script>


    <script>
(function (window) {
    var INSIGHT_CONFIG = {
        TRANSLATION: {
            POSTS: 'Posts',
            PAGES: 'Pages',
            CATEGORIES: 'Categories',
            TAGS: 'Tags',
            UNTITLED: '(Untitled)',
        },
        ROOT_URL: '/blog/',
        CONTENT_URL: '/blog/content.json',
    };
    window.INSIGHT_CONFIG = INSIGHT_CONFIG;
})(window);
</script>

<script src="/blog/js/insight.js"></script>






   




   
    
  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/valine"></script>
  <script type="text/javascript">
  var GUEST = ['nick', 'mail', 'link'];
  var meta = 'nick,mail,link';
  meta = meta.split(',').filter(function(item) {
    return GUEST.indexOf(item) > -1;
  });
  new Valine({
    el: '#vcomments',
    verify: false,
    notify: false,
    appId: '',
    appKey: '',
    placeholder: 'Just go go',
    avatar: 'mm',
    meta: meta,
    pageSize: '10' || 10,
    visitor: false
  });
  </script>

     







</body>
</html>